﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace SpiderHelper.Model
{
    /// <summary>
    /// 采集来的内容
    /// </summary>
    public class TempDoc
    {
        /// <summary>
        /// 编号
        /// </summary>
        public int Id { get; set; }
        /// <summary>
        /// 标题
        /// </summary>
        public string Title { get; set; }
        /// <summary>
        /// 描述
        /// </summary>
        public string Description { get; set; }
        /// <summary>
        /// 链接
        /// </summary>
        public string Link { get; set; }
        /// <summary>
        /// 保存时间
        /// </summary>
        public DateTime Pdate { get; set; }
        /// <summary>
        /// 来源网站
        /// </summary>
        public int SiteId { get; set; }
        /// <summary>
        /// 来源频道
        /// </summary>
        public int ChannelId { get; set; }
        /// <summary>
        /// 来源/作者
        /// </summary>
        public string Author { get; set; }
        /// <summary>
        /// 信息内容
        /// </summary>
        public string Content { get; set; }
        /// <summary>
        /// 关键字
        /// </summary>
        public string Tag { get; set; }
        /// <summary>
        /// 已确认
        /// </summary>
        public int Sured { get; set; }

        public TempDoc()
        {
            this.ChannelId = int.MinValue;
            this.Id = int.MinValue;
            this.SiteId = int.MinValue;
            this.Sured = int.MinValue;
        }


        /// <summary>
        /// 判断新闻是否已经被存储过
        /// </summary>
        /// <param name="Title"></param>
        public bool IsInserted(string link, DavidDB.ADO.DBManager db)
        {
            bool _isInserted = false;

            TempDoc doc = new TempDoc();
            doc.Link = link;

            var query = db.GetSomeObject(doc);
            if (query.Count() > 0)
            {
                _isInserted = true;
            }


            return _isInserted;
        }
    }
}
